<extend name="Base/common"/>

<block name="style">
    <style type="text/css">
        .nav-pills{
            border-bottom: 1px solid #d3d1e5;
        }
        .nav-pills>li>a{
            border-radius: 0px;
        }
        .nav-pills>li.active>a, 
        .nav-pills>li.active>a:focus, 
        .nav-pills>li.active>a:hover{
            background-color: #fff;
            color: #8084e7;
            border-bottom: 2px solid #8084e7;
        }
    </style>
</block>

<block name="body">
    <div id="page-wrapper" style="padding-left: 20px;padding-right: 20px;overflow: auto;">
        <div class="col-md-12 col-sm-12" style="padding-left: 0px;padding-right: 0px;">
           <div id="page-inner">                
                <div>
                    <div class="row">
                        <div class="col-md-8 col-sm-12 col-xs-12 w_clink_left">
                            <div class="w_clink_left_div">
                                <form class="row w_form1" id="search_form" action="{:U('Index/ajaxPostBidGood',array('id'=>I('get.id'),'is_end'=>0))}">
                                    <div class="form-group col-md-3">
                                        <label for="cate">类型</label>
                                        <select class="form-control" name="cate_id" id="cate">
                                           <option value="{$vo.id}">请选择</option>
                                          <volist name="cateList" id="vo">
                                             <option value="{$vo.id}">{$vo.name}</option>
                                          </volist>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-3">
                                        <label for="brand">品牌</label>
                                        <select class="form-control" name="brand_id" id="brand">
                                          <option value="{$vo.id}">请选择</option>
                                          <volist name="brandList" id="vo">
                                             <option value="{$vo.id}">{$vo.name}</option>
                                          </volist>
                                        </select>
                                    </div>
                                   <div class="form-group col-md-3">
                                        <label for="model">型号</label>
                                        <select class="form-control" name="model_id" id="model">
                                          <option value="{$vo.id}">请选择</option>
                                          <volist name="modelList" id="vo">
                                             <option value="{$vo.id}">{$vo.name}</option>
                                          </volist>
                                        </select>
                                    </div>
                                    <div class="form-group col-md-1">
                                        <label for="search" style="opacity: 0;">1</label>
                                        <button type="button" id="search" class="btn btn-default form-control w_clink_left_btn">查询</button>
                                    </div>
                                    <div class="form-group col-md-1">
                                        <label style="opacity: 0">1</label>
                                        <button type="button" id="refresh" class="btn btn-default form-control">重置</button>
                                    </div>
                                </form>
                                <div class="row w_clink_tableleft">
                                    <table class="table table-hover" style="border: 1px solid #ddd;margin-bottom: 0px;" id="good_list">
                                        <tr class="active w_table_tr1">
                                            <td>sku</td>
                                            <td>等级（数量）</td>
                                            <td>供货量</td>
                                        </tr>
                                        <?php $store_count=0;$store_price=0; ?>
                                      <volist name="good_list" id="vo">  
                                        <?php
                                            $goods=M('goods')->where(array('id'=>$vo['good_id']))->find();
                                            $store_count+=$vo['store_count'];
                                            $store_price+=$vo['star_price'];
                                        ?>
                                        <tr>
                                            <td>{$goods['goods_name']}</td>
                                            <td>{$goods['level']}</td>
                                            <td>{$vo.store_count}</td>
                                        </tr>
                                      </volist>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4 col-sm-3 col-xs-3 w_clink_right">
                            <div class="row w_clink_right_div">竞价中</div>
                            <div class="row w_clink_right_div2">
                                <table class="table w_clink_table_tr">
                                    <tr>
                                        <td>竞价单号</td>
                                        <td>{$data.bid_sn}</td>
                                    </tr>
                                    <tr>
                                        <td>名称</td>
                                        <td>{$data.name}</td>
                                    </tr>
                                    <tr>
                                        <td>创建时间</td>
                                        <td>{$data.start_time|time_format='Y-m-d H:i:s'}</td>
                                    </tr>
                                    <tr style="border-top: 1px solid #ddd">
                                        <td>物品总数</td>
                                        <td><b>{$store_count}</b>(个)</td>
                                    </tr>
                                    <tr>
                                        <td>起拍价</td>
                                        <td>￥<b>{$store_price}</b></td>
                                    </tr>
                                    <tr>
                                        <td>我的报价</td>
                                        <td>
                                           <?php
                                             $where['bid_id']=$data['id'];
                                             $where['user_id']=is_login();
                                             $user_bind=M('bid_user')->where($where)->find();
                                             
                                           ?> 
                                         <empty name="user_bind">
                                           <div>
                                            <input type="text" data-numbers="{$store_count}" data-starprice="{$store_price}" name="user_price" class="w_input__inner">
                                            <a href="javascript:" onclick="submitBtn($(this))"><img src="__IMG__/ok.png"></a>
                                           </div> 
                                         <else />   
                                           <div style="display: none;" id="user_input">
                                            <input type="text" data-numbers="{$store_count}" data-starprice="{$store_price}" value="{$user_bind.user_price}" name="user_price" class="w_input__inner">
                                            <a href="javascript:" onclick="submitBtn($(this))"><img src="__IMG__/ok.png"></a>
                                           </div> 

                                           <sapn>￥<b style='color:#8084e7' onclick="showInput($(this))">{$user_bind.user_price}</b></sapn>
                                         </empty>  
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>                        
                    </div>
                    
                </div>
           </div>                    
         </div>
        <!-- /. PAGE INNER  -->
    </div>
</block>
<block name="script">
 <script type="text/javascript">



        //用户提交
        function submitBtn(self){
          var input=self.siblings('input'); 
          var user_number=input.attr('data-numbers'),
              user_price=input.val(),
              bid_type="{$data['cate_id']}",
              bid_id="{$data['id']}";

         var user_star_price=input.attr('data-starprice');

         if(user_price==''){
            layer.msg('请填写报价');
            return false;
         }   

         if(user_price<user_star_price){
            layer.msg('不能低于起拍价');
            return false;
         }
          
          $.ajax({
                    type:'POST',
                    data:{
                        bid_id:bid_id,
                        user_number:user_number,
                        user_price:user_price,
                        bid_type:bid_type}, 
                    url:"{:U('ajaxPostUserBid')}",
                    success:function(data){                            
                          if(data.status==1){   
                            layer.msg('提交成功', {icon: 6});
                            var html="￥<b style='color:#8084e7'>"+user_price+"</b>";
                            self.parents('td').html(html);               
                          }else{
                            layer.msg(data.msg, {icon: 5});
                          }
                    }
            });           

        }
    </script>
</block>